package com.acmedcare.framework.exchange.center;

import com.acmedcare.framework.exchange.center.core.PluginContainerMBean;
import com.acmedcare.framework.exchange.center.core.PluginMetadata;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "插件监控数据展示")
@RequestMapping("/plugin-monitor")
public class PluginMonitorEndpoint {

  final PluginContainerMBean pluginContainer;

  public PluginMonitorEndpoint(
      PluginContainerMBean pluginContainer) {
    this.pluginContainer = pluginContainer;
  }

  @GetMapping("plugins")
  @ApiOperation("获取所有内存插件数据!")
  public ResponseEntity<List<PluginMetadata>> getAllPlugins() {

    return ResponseEntity.ok(pluginContainer.getPlugins());
  }
}
